package cn.lut.springboot.web;

import cn.lut.springboot.entity.Student;
import cn.lut.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @user:dell
 * @date:2021年01月01 21:16
 */
//@Controller
@RestController    //相当于控制层类上加@controller+方法上加@responseBody
//意味着当前控制层类中所有方法返回的都是json对象
public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping("/student")
//    @ResponseBody
    public Object student(Integer id){
     Student student= studentService.queryStudentById(id);
     return student;
    }
    @RequestMapping(value = "/update")
//    @ResponseBody
    public Object update(Integer id,String name){
        Student student=new Student();
        student.setId(id);
        student.setName(name);
      int updateCount = studentService.updateStudentById(student);
      return "修改学生编号为:"+id+"的姓名修改结果"+updateCount;
    }
}
